package com.xzuf.extend;

import java.util.Enumeration;

import javax.swing.JPanel;

import com.l2fprod.common.propertysheet.DefaultProperty;
import com.l2fprod.common.propertysheet.PropertySheet;
import com.l2fprod.common.propertysheet.PropertySheetPanel;
import com.l2fprod.common.swing.LookAndFeelTweaks;
import com.xzuf.plugin.IModulePlugin;

/**
 * Java属性�ϵͳ����
 * @author xzgf
 * @since 2008-9-1
 * @version 1.0
 */
public class JavaSystemProperty implements IModulePlugin {

	/**
	 * {@inheritDoc}
	 */
	@Override
	public int getCurrentOpState() {
		return 0;
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public void setCurrentOpState(int state) {
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public JPanel start() {
		
		JPanel panel = new JPanel();
		panel.setLayout(LookAndFeelTweaks.createVerticalPercentLayout());

		final PropertySheetPanel sheet = new PropertySheetPanel();
	    sheet.setMode(PropertySheet.VIEW_AS_CATEGORIES);
	    sheet.setDescriptionVisible(true);
	    sheet.setSortingCategories(true);
	    sheet.setSortingProperties(true);
	    sheet.setRestoreToggleStates(true);
	    panel.add(sheet, "*");
	    DefaultProperty bean = null;
	    DefaultProperty rootProperty = new DefaultProperty();
	    rootProperty.setCategory("JavaProperty");
	    rootProperty.setDisplayName("属性");
	    Enumeration enums = System.getProperties().propertyNames();

		while(enums.hasMoreElements()) {
			bean = new DefaultProperty();
			bean.setParentProperty(rootProperty);
			bean.setType(String.class);
			bean.setCategory("JavaProperty");
			Object o = enums.nextElement();
			bean.setDisplayName(String.valueOf(o));
			bean.setValue(System.getProperty(String.valueOf(o)));
			bean.setName(String.valueOf(o));
			bean.setShortDescription(System.getProperty(String.valueOf(o)));
			sheet.addProperty(bean);
		}
	    
	
		
		return panel;
	}
}
